#ifndef INPUT_H
#define INPUT_H

#include "fabric.h"
#include "color.h"
#include "matrix.h"
#include <vector>
#include <QFile>
#include <QTimer>
#include <QObject>

#include "defines/global.h"

class Input : public QObject
{
    Q_OBJECT

    public:
        Input();

        ~Input();

        std::vector<Fabric *> parse(QFile*, unsigned int, double *, double *);

        std::vector<Fabric *> CAparse(double *, double *);

        std::vector<Fabric *> OBJparse(unsigned int);

        std::vector<Fabric *> *parse(QFile*);
        std::vector<Fabric *> *playbackParse();

    signals:
        void playbackEnded();

    public slots:
        void startPlayback();
        void pausePlayback();
        void stopPlayback();
        void updatePlayback();

    private:
        bool playbackEnd;
        QFile *file;
        QFile *playbackFile;
        QTextStream streamPlayback;
        std::vector<Fabric *> playbackFabrics;
        QTimer *timer;

//        qint64 initialPosInPlayback;
//        qint64 posInPlayback;
        double timeInPlayback;

        Matrix toMatrixNx3(unsigned int, std::vector<int>);

        bool createSpring(Particle *, Particle *, std::vector<Spring *> *, unsigned int, const Color &, unsigned int);
};

#endif
